Skip to content

feat: research workflows & rich search with user-selectable sources - #437

Open
sadiqabubakar826-del wants to merge 1 commit into
Emmy123222:mainfrom
sadiqabubakar826-del:feat/research-workflows-rich-search
Open

feat: research workflows & rich search with user-selectable sources#437
sadiqabubakar826-del wants to merge 1 commit into
Emmy123222:mainfrom
sadiqabubakar826-del:feat/research-workflows-rich-search

Conversation

@sadiqabubakar826-del

Copy link
Copy Markdown

Research Workflows & Rich Search

Replaces the fixed "first 5 results" summarize button with a full research workflow that lets
users control the evidence set and output format before invoking AI.

What changed

New: ResearchWorkflowPanel component

  • Checklist of all result sources — users check/uncheck which ones to include
  • Select all / deselect all shortcuts
  • 4 report format options: Bullet Points, Narrative, Table, Comparison
  • Generate Report button (disabled until at least one source is selected)
  • Streams the AI response live via SSE, rendered through AiMarkdown with clickable [N]
    citations that scroll to the source card
  • Footer shows which sources were omitted (deselected by user) or failed, by citation number

Updated: SearchResults.tsx

  • Added RESEARCH button alongside the existing SUMMARIZE button
  • Each result card now has id="result-card-{n}" so citation links can scroll to them
  • AiMode state (none | summarize | research) — the panels are mutually exclusive and both reset
    when the query or results change

Updated: aiChatService.ts

  • New buildResearchPrompt(query, sources, format, allSourceIds) helper
  • Produces format-specific prompts with inline source blocks and a "Sources Used" trailer
  • Returns omittedIds — the source IDs present in the full result set but excluded from the
    selected set, for recording in the report metadata

Updated: mcp-server/index.ts — ai_summarize tool

  • Optional format parameter: bullets | narrative | table | comparison
  • When provided, replaces the generic instruction with a structured output directive
  • Fully backward-compatible — omitting format keeps existing behaviour

New types in src/types/index.ts

  • ReportFormat, ResearchReportConfig, SourceStatus, ResearchReport

Tests

  • buildResearchPrompt: all 4 formats, omittedIds computation, prompt content, source ordering
  • ResearchWorkflowPanel: source selection, format switching, generate flow, error states,
    omitted-source footer, state reset on query change
  • SearchResults: legacy summarize reset behaviour preserved, new research mode toggle, citation
    card IDs

What was tested

  • buildResearchPrompt — 27 new tests, all passing
  • Component and integration tests written for all new behaviour
  • Legacy SUMMARIZE flow is unchanged; existing tests continue to cover it
  • MCP ai_summarize change is backward-compatible and covered by existing MCP tool tests

Notes

  • Browser, Express, Vercel, and MCP contracts remain aligned — no paid routes were modified
  • x402 settlement and explicit user approval are untouched
  • The /ai/chat endpoint (free, no payment) is the only backend call made by the research
    workflow

closes #307

- Add ReportFormat, ResearchReportConfig, SourceStatus, ResearchReport
  types to src/types/index.ts
- Add ResearchSource, ResearchPromptResult interfaces and
  buildResearchPrompt() helper to src/lib/aiChatService.ts — builds
  format-specific prompts (bullets/narrative/table/comparison) and
  computes omitted source IDs
- Add ResearchWorkflowPanel component: source checkbox list with
  select-all/none, 4 format radio options, Generate Report button,
  SSE-streaming report via AiMarkdown, omitted/failed source footer
- Update SearchResults.tsx: RESEARCH button alongside SUMMARIZE,
  AiMode state (none/summarize/research), result cards get
  id=result-card-{n} for citation scrolling, state reset on
  query/results change
- Update mcp-server/index.ts ai_summarize tool: optional format param
  (bullets|narrative|table|comparison) with format-specific directives,
  backward-compatible default behaviour
- Add tests: buildResearchPrompt (all 4 formats, omittedIds, prompt
  content), ResearchWorkflowPanel (source selection, format, generate,
  error, reset), SearchResults (legacy summarize + research mode +
  citation card IDs)
@vercel

vercel Bot commented Sep 5, 2026

Copy link
Copy Markdown

@sadiqabubakar826-del is attempting to deploy a commit to the Emmanuel's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Sep 5, 2026

Copy link
Copy Markdown

@sadiqabubakar826-del Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate a report from user-selected search results

1 participant